/*    */ package com.fizz.redpacket.config;

/*    */
/*    */ import javax.sql.DataSource;
/*    */ import org.apache.ibatis.session.SqlSessionFactory;
/*    */ import org.mybatis.spring.SqlSessionFactoryBean;
/*    */ import org.mybatis.spring.SqlSessionTemplate;
/*    */ import org.springframework.beans.factory.annotation.Qualifier;
/*    */ import org.springframework.boot.context.properties.ConfigurationProperties;
/*    */ import org.springframework.boot.jdbc.DataSourceBuilder;
/*    */ import org.springframework.context.annotation.Bean;
/*    */ import org.springframework.context.annotation.Configuration;
/*    */ import org.springframework.core.io.support.PathMatchingResourcePatternResolver;
/*    */ 
/*    */ 
/*    */ 
/*    */ 
/*    */ 
/*    */ 
/*    */ 
/*    */ 
/*    */ 
/*    */ 
/*    */ 
/*    */ @Configuration
/*    */ public class SecondaryConfig
/*    */ {
/*    */   @Bean(name = {"SecondaryDataSource"})
/*    */   @ConfigurationProperties(prefix = "spring.datasource.secondary")
/*    */   public DataSource getPrimaryDateSource() {
/* 30 */     return DataSourceBuilder.create().build();
/*    */   }
/*    */ 
/*    */   
/*    */   @Bean(name = {"SecondarySqlSessionFactory"})
/*    */   public SqlSessionFactory primarySqlSessionFactory(@Qualifier("SecondaryDataSource") DataSource datasource) throws Exception {
/* 36 */     SqlSessionFactoryBean bean = new SqlSessionFactoryBean();
/* 37 */     bean.setDataSource(datasource);
/* 38 */     bean.setMapperLocations((new PathMatchingResourcePatternResolver())
/* 39 */         .getResources("classpath:mapper/**/*.xml"));
/* 40 */     return bean.getObject();
/*    */   }
/*    */ 
/*    */   
/*    */   @Bean({"SecondarySqlSessionTemplate"})
/*    */   public SqlSessionTemplate primarySqlSessionTemplate(@Qualifier("SecondarySqlSessionFactory") SqlSessionFactory sessionfactory) {
/* 46 */     return new SqlSessionTemplate(sessionfactory);
/*    */   }
/*    */ }


/* Location:              /home/fizz/Music/大学学习的知识总结/收获比较大的项目/redpacket/redpacket/src/main/docker8081/redpacket-0.0.1-SNAPSHOT.jar!/BOOT-INF/classes/com/fizz/redpacket/config/SecondaryConfig.class
 * Java compiler version: 8 (52.0)
 * JD-Core Version:       1.1.3
 */